<template>
    <div>
        <button @click="show">显示/隐藏</button>
        <transition-group name="hello" appear>
            <h2 v-show="isShow" key="1">培立优</h2>
            <h2 v-show="!isShow" key="2">家动员</h2>
        </transition-group>        
    </div>
</template>

<script>
export default {
    name:'TestComponent2',
    data(){
        return {
            isShow: true
        };
    },
    methods:{
        show(){
            this.isShow = !this.isShow;
        }
    }
}
</script>

<style scoped>
h2{
    background-color: peru;
}
.hello-enter-active{
    transition: 4s linear;
}
.hello-leave-active{
    transition: 2s linear;
}
/* 进入的起点 */
.hello-enter{
    transform: translateX(-100%);
}
/* 进入的终点 */
.hello-enter-to{
    transform: translateX(0);
}
/* 离开的起点 */
.hello-leave{
    transform: translateX(0);
}
/* 离开的终点 */
.hello-leave-to{
    transform: translateX(100%);
}
</style>